package main;

import org.eclipse.emf.common.util.Diagnostic;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.Diagnostician;

import statemachine.Activity;
import statemachine.ActivityTransition;
//import statemachine.Event;
//import statemachine.Result;
import statemachine.State;
import statemachine.StateTransition;
import statemachine.StateType;
import statemachine.Statemachine;
import statemachine.StatemachineFactory;

/**
 * This state machine models every concept we have in Mood. That is:
 * 
 * <ol>
 * <li>States (in Danish: Tilstande)</li>
 * <li>Events (in Danish: H�ndelser)</li>
 * <li>Results (in Danish: Resultater)</li>
 * <li>StateTransitions (in Danish: Tilstandsregler)</li>
 * <li>ActivityTransitions (in Danish: Resultatregler)</li>
 * 
 * * The main benefit of this model is:
 * <ol>
 * <li>Type safety, as we have separate Java types for conceptually different things e.g. States and Activities</li>
 * <li>The developer does need to know about the concepts from Mood - it is
 * just a state machine</li>
 * </ol>
 * 
 * The main drawback of this model is:
 * <ol>
 * <li>The model is somewhat complex, perhaps even over engineered</li>
 * </ol>
 * 
 * @author Kim
 * 
 */
public class Main {

	public static void main(String[] args) {

//		State stateA = StatemachineFactory.eINSTANCE.createState();
//		stateA.setType(StateType.START);
//
//		State stateB = StatemachineFactory.eINSTANCE.createState();
//		stateB.setType(StateType.STOP);
//
//		Activity activity = StatemachineFactory.eINSTANCE.createActivity();
//
//		StateTransition stateTransition = StatemachineFactory.eINSTANCE
//				.createStateTransition();
//		Event event = StatemachineFactory.eINSTANCE.createEvent();
//		event.setName("Start");
//		stateTransition.setEvent(event);
//		stateTransition.setStateToActivityTransition(activity);
//		stateA.getStateTransitions().add(stateTransition);
//
//		ActivityTransition activityTransition = StatemachineFactory.eINSTANCE
//				.createActivityTransition();
//		Result result = StatemachineFactory.eINSTANCE.createResult();
//		result.setName("Resultat");
//		activityTransition.setActivityToStateTransition(stateB);
//		activityTransition.setResult(result);
//		activity.getActivityTransitions().add(activityTransition);
//
//		Statemachine statemachine = StatemachineFactory.eINSTANCE
//				.createStatemachine();
//		statemachine.setName("Simple state machine");
//		statemachine.getStates().add(stateA);
//		statemachine.getStates().add(stateB);
//		statemachine.getActivities().add(activity);
//
//		diagnose(statemachine);
	}

	private static void diagnose(EObject object) {
		Diagnostic validate = Diagnostician.INSTANCE.validate(object);
		for (Diagnostic dia : validate.getChildren()) {
			System.err.println(dia.getMessage() + ". Severity: "
					+ (dia.getSeverity() == Diagnostic.ERROR));

		}
	}

}
